package com.dha.adapter;

import java.util.ArrayList;
import java.util.List;

import com.dha.caodangcongnghe.R;
import com.dha.model.ThongBaoModel;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ThongBaoAdapter extends ArrayAdapter<ThongBaoModel> {

	private Context context;
	private int layout_custom;
	private ArrayList<ThongBaoModel> arr;
	public ThongBaoAdapter(Context context, int resource,
			ArrayList<ThongBaoModel> objects) {
		super(context, resource, objects);
		this.context = context;
		layout_custom = resource;
		arr = objects;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(context.LAYOUT_INFLATER_SERVICE);
		
		convertView = inflater.inflate(layout_custom, parent, false);
		
		TextView tvTieuDe = (TextView) convertView.findViewById(R.id.tv_custom_tinThongBao_tieuDe);
		TextView tvNoiDung = (TextView) convertView.findViewById(R.id.tv_custom_tinThongBao_noiDung);
		TextView tvNguoiDang = (TextView) convertView.findViewById(R.id.tv_custom_tinThongBao_nguoiGoi);
		TextView tvNgayDang = (TextView) convertView.findViewById(R.id.tv_custom_tinThongBao_ngayGoi);
		
		tvTieuDe.setText(arr.get(position).getTieuDe().toString());
		tvNoiDung.setText(arr.get(position).getNoiDung().toString());
		tvNguoiDang.setText(arr.get(position).getNguoiThongBao().toString());
		tvNgayDang.setText(arr.get(position).getNgayThongBao().toString());
		
		return convertView;
	}

	
}
